<!DOCTYPE html>
<html>
<head>
	<title>event对象</title>
	<meta charset="utf-8">
</head>
<body>
	<button>event对象</button>
	<div style="width:200px; height: 100px;background: red"></div>
	<div style="width:200px; height: 100px;background: green"></div>
	<div style="width:200px; height: 100px;background: yellow;position: absolute;top: 20px;"></div>
	<script type="text/javascript">
		var btn1 = document.getElementsByTagName("button")[0];
		// 谷歌 IE8以上支持event对象
		btn1.onclick = function(){
			console.log(event);
		}

		// 火狐只支持传参
		btn1.onclick = function(e){
			console.log(e);
		}
		
		// 兼容性写法 及鼠标位置
		document.onclick = function(e){
			var oEv = e || event;
			console.log("当前鼠标的位置" + oEv.clientX + "," + oEv.clientY);
		}

		// 兼容性写法 及获取按键
		document.onkeydown = function(e){
			var oEv = e || event;
			console.log("按上键的keycode是：" + oEv.keyCode);
		}



	</script>
</body>
</html>